/*
 * Copyright 2012 Victor.
 */
package lab1.models;

import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import lab1.lib.db.DepartmentTable;
import lab1.lib.db.EmployeeTable;
import lab1.lib.db.SaleGradeTable;

/**
 *
 * @author Victor
 */
public class Employee
{
   private Integer id;
   
   private String name;
   
   private String job;
   
   private Employee manager;
   
   private Date hiredate;
   
   private Integer salary;
   
   /**
    * @todo rename. What is comm?
    */
   private Integer comm;
   
   private Department department;
   
   private SaleGrade salegrade;

    /**
     * @return the id
     */
    public Integer getId()
    {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(Integer id)
    {
        this.id = id;
    }

    /**
     * @return the name
     */
    public String getName()
    {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name)
    {
        this.name = name;
    }

    /**
     * @return the job
     */
    public String getJob()
    {
        return job;
    }

    /**
     * @param job the job to set
     */
    public void setJob(String job)
    {
        this.job = job;
    }

    /**
     * @return the manager
     */
    public Employee getManager()
    {
        return manager;
    }

    /**
     * @param manager the manager to set
     */
    public void setManager(Employee manager)
    {
        this.manager = manager;
    }
    
    /**
     * Set manager by id.
     * 
     * @param manager the manager to set
     */
    public void setManager(String manager)
    {
        this.manager = EmployeeTable.getById(Integer.parseInt(manager));
    }

    /**
     * @return the hiredate
     */
    public Date getHiredate()
    {
        return hiredate;
    }

    /**
     * @param hiredate the hiredate to set
     */
    public void setHiredate(Date hiredate)
    {
        this.hiredate = hiredate;
    }
    
    /**
     * Try to parse hire date.
     * 
     * @param hiredate the hiredate to set
     */
    public void setHiredate(String hiredate) throws ParseException
    {
        this.hiredate = DateFormat.getInstance().parse(hiredate);
    }

    /**
     * @return the salary
     */
    public Integer getSalary()
    {
        return salary;
    }

    /**
     * @param salary the salary to set
     */
    public void setSalary(Integer salary)
    {
        this.salary = salary;
    }

    /**
     * @return the comm
     */
    public Integer getComm()
    {
        return comm;
    }

    /**
     * @param comm the comm to set
     */
    public void setComm(Integer comm)
    {
        this.comm = comm;
    }

    /**
     * @return the department
     */
    public Department getDepartment()
    {
        return department;
    }

    /**
     * @param department the department to set
     */
    public void setDepartment(Department department)
    {
        this.department = department;
    }

    /**
     * Set department by id.
     * 
     * @param department the department to set
     */
    public void setDepartment(String department)
    {
        this.department = DepartmentTable.getById(Integer.parseInt(department));
    }

    /**
     * @return the salegrade
     */
    public SaleGrade getSalegrade()
    {
        return salegrade;
    }

    /**
     * @param salegrade the salegrade to set
     */
    public void setSalegrade(SaleGrade salegrade)
    {
        this.salegrade = salegrade;
    }

    /**
     * Set salegrade by id.
     * 
     * @param salegrade the salegrade to set
     */
    public void setSalegrade(String salegrade)
    {
        this.salegrade = SaleGradeTable.getById(Integer.parseInt(salegrade));
    }
}
